from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base


Base = declarative_base()


class Users(Base):
    __tablename__ = 'users2'
    id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String(32))
    extra = Column(String(16))


def init_db():
    engine = create_engine("mysql+pymysql://root:qaz3357375@127.0.0.1:3306/test?charset=utf8", max_overflow=5)
    Base.metadata.create_all(engine)  # 创建表


def drop_db():
    engine = create_engine("mysql+pymysql://root:qaz3357375@127.0.0.1:3306/test?charset=utf8", max_overflow=5)
    Base.metadata.drop_all(engine)  # 删除表

# 寻找Base的所有子类，按照子类的结构在数据库中生成对应的数据表信息


if __name__ == '__main__':
    init_db()
    pass
